package general.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class LocationDO
	{
		public var INTERNAL_LOC_NUM:String = "0";
		public var LOCATION:String = "";
		public var WAREHOUSE:String = "";
		public var ZONE:String = "";
		public var LOCATION_CLASS:String = "";
		public var LOCATION_TYPE:String = "";
		public var MULTI_ITEM:String = "";
		public var TRACK_LPN:String = "N";
		public var LOCATION_STS:String = "Empty";
		public var LAST_CYCLE_COUNT_DATE:String = DateManager.GetTodayString();
		public var ACTIVE:String = "Y";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var TEMPLATE_FIELD1:String = "";
		public var TEMPLATE_FIELD2:String = "";
		public var TEMPLATE_FIELD3:String = "";
		public var TEMPLATE_FIELD4:String = "";
		public var TEMPLATE_FIELD5:String = "";
		public var MIN_QTY_UM:String = "EA";
		
		public function LocationDO()
		{
		}

		public function Init(xmlObj:XML):void
		{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML
		{
			var xmlObj:XML =
				<LOCATION>
					<INTERNAL_LOC_NUM>{INTERNAL_LOC_NUM}</INTERNAL_LOC_NUM>
					<LOCATION>{LOCATION}</LOCATION>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<ZONE>{ZONE}</ZONE>
					<LOCATION_TYPE>{LOCATION_TYPE}</LOCATION_TYPE>
					<LOCATION_CLASS>{LOCATION_CLASS}</LOCATION_CLASS>
					<MULTI_ITEM>{MULTI_ITEM}</MULTI_ITEM>
					<TRACK_LPN>{TRACK_LPN}</TRACK_LPN>
					<LOCATION_STS>{LOCATION_STS}</LOCATION_STS>
					<LAST_CYCLE_COUNT_DATE>{LAST_CYCLE_COUNT_DATE}</LAST_CYCLE_COUNT_DATE>
					<ACTIVE>{ACTIVE}</ACTIVE>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<TEMPLATE_FIELD1>{TEMPLATE_FIELD1}</TEMPLATE_FIELD1>
					<TEMPLATE_FIELD2>{TEMPLATE_FIELD2}</TEMPLATE_FIELD2>
					<TEMPLATE_FIELD3>{TEMPLATE_FIELD3}</TEMPLATE_FIELD3>
					<TEMPLATE_FIELD4>{TEMPLATE_FIELD4}</TEMPLATE_FIELD4>
					<TEMPLATE_FIELD5>{TEMPLATE_FIELD5}</TEMPLATE_FIELD5>
					<MIN_QTY_UM>{MIN_QTY_UM}</MIN_QTY_UM>			
				</LOCATION>;
			return xmlObj;
		}
				
		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:LocationDO = new LocationDO();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}
	}
}